import { getUserInfoStorageSync } from './storageSync'

/**
 * 获取当前用户信息
 * @returns {Object|null} 用户信息对象或null
 */
export const getCurrentUser = () => {
  return getUserInfoStorageSync()
}

/**
 * 获取当前用户ID
 * @returns {string|null} 用户ID或null
 */
export const getCurrentUserId = () => {
  const userInfo = getCurrentUser()
  return userInfo?.userId || null
}

/**
 * 获取当前用户名
 * @returns {string|null} 用户名或null
 */
export const getCurrentUserName = () => {
  const userInfo = getCurrentUser()
  return userInfo?.userName || userInfo?.name || null
}

/**
 * 获取当前用户手机号
 * @returns {string|null} 手机号或null
 */
export const getCurrentUserMobile = () => {
  const userInfo = getCurrentUser()
  return userInfo?.mobile || null
}

/**
 * 检查用户是否已登录
 * @returns {boolean} 是否已登录
 */
export const isUserLoggedIn = () => {
  const userInfo = getCurrentUser()
  return !!userInfo && !!userInfo.userId
}

/**
 * 获取用户权限菜单
 * @returns {Array} 权限菜单数组
 */
export const getUserAuthMenus = () => {
  const userInfo = getCurrentUser()
  return userInfo?.authMenuList || []
}
